Skip to content

🧹 [code health improvement] update bash test replacer string#99

Merged
bashandbone merged 4 commits intomainfrom
fix/bash-test-replacer-761935811020712664
Mar 9, 2026
Merged

🧹 [code health improvement] update bash test replacer string#99
bashandbone merged 4 commits intomainfrom
fix/bash-test-replacer-761935811020712664

Conversation

@bashandbone
Copy link
Contributor

@bashandbone bashandbone commented Mar 9, 2026

🎯 What: Updated the test replacement string in test_bash_replace from log 123 to log $A. This successfully resolves the TODO: change the replacer to log $A comment in crates/language/src/bash.rs.

💡 Why: This changes the test from simply verifying a hardcoded string substitution to testing variable interpolation during the replacement process. Using log $A checks that $A is properly capturing the match 123 from echo 123, which provides a much more robust and accurate test of the ast-grep pattern matching and replacement engine for Bash code. It improves the quality and intent of the test coverage.

Verification: Ran cargo test -p thread-language test_bash_replace to ensure the specific test passes and also ran cargo +nightly test --workspace --no-run to ensure the workspace compiles successfully without introducing errors.

Result: Improved test case coverage by actively testing variables correctly in bash code replacements without changing functional behavior.


PR created automatically by Jules for task 761935811020712664 started by @bashandbone

Summary by Sourcery

Tests:

  • Update the Bash replacement test to use a variable-based replacer string instead of a hardcoded literal.

Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 9, 2026 21:54
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Mar 9, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the Bash replacement test to validate variable interpolation by using a replacer that references the captured match via $A instead of a hardcoded literal string.

Sequence diagram for updated Bash replacement test behavior

sequenceDiagram
    participant TestRunner
    participant test_bash_replace
    participant test_replace
    participant BashEngine

    TestRunner->>test_bash_replace: run()
    test_bash_replace->>test_replace: test_replace("echo 123", "echo $A", "log $A")
    test_replace->>BashEngine: applyPattern("echo 123", pattern echo $A)
    BashEngine-->>test_replace: captures A = 123
    test_replace->>BashEngine: applyReplacement("log $A", A = 123)
    BashEngine-->>test_replace: "log 123"
    test_replace-->>test_bash_replace: ret = "log 123"
    test_bash_replace->>test_bash_replace: assert_eq(ret, "log 123")
    test_bash_replace-->>TestRunner: success
Loading

File-Level Changes

Change Details Files
Strengthens the Bash replacement unit test to assert variable-based substitution instead of a fixed string replacement.
  • Removed outdated TODO comment about changing the replacer to use log $A
  • Updated the replacer argument in the Bash test from a hardcoded string to one using the $A capture variable while keeping the expected output the same
crates/language/src/bash.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Bash language replacement test to validate variable capture/interpolation in the replacement string, aligning the test with the intended ast-grep pattern/replacer behavior for Bash.

Changes:

  • Updated test_bash_replace to use log $A as the replacer instead of a hardcoded log 123.
  • Removed the now-obsolete TODO comment about changing the replacer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

google-labs-jules bot and others added 3 commits March 9, 2026 22:07
Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
@bashandbone bashandbone merged commit 1eca1ad into main Mar 9, 2026
21 of 31 checks passed
@bashandbone bashandbone deleted the fix/bash-test-replacer-761935811020712664 branch March 9, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants